<template>
  <div id="home">
    <nav-bar class="home-nav">
      <div slot="center">购物街</div>
    </nav-bar>
    <div class="swiper-wrapper">
      <swiper ref="mySwiper" :options="swiperOptions">
        <swiper-slide v-for="item in bannerList"><img :src="item.banner" class="swiper-img"></swiper-slide>
        <div class="swiper-pagination" slot="pagination"></div>
      </swiper>
    </div>
  </div>
</template>

<script>
  import NavBar from "components/common/navbar/NavBar";
  import {getTopdata} from '../../network/home'
  import 'swiper/dist/css/swiper.css'
  import { swiper, swiperSlide } from 'vue-awesome-swiper'

  export default {
    name: "Home",
    components: {
      NavBar,
      swiper,
      swiperSlide,
    },
    data() {
      return {
        bannerList: [],
        fixedList: [],
        swiperOptions: {
          loop: true,
          speed: 500,
          autoplay:{
            delay: 2000,
            stopOnLastSlide: false,
            /* 触摸滑动后是否继续轮播 */
            disableOnInteraction: false
          },
          pagination: {

            el: '.swiper-pagination',

          }
        }
      }
    },
    created() {
      // 1.请求多个数据
      getTopdata().then((res) => {
        this.bannerList = res.banner_list
        this.fixedList = res.fixed_list
      })
    },
    methods: {
      bannerArr() {

      }
    }
  }
</script>

<style scoped>
  .home-nav {
    background-color: var(--color-tint);
    box-shadow: 0 1px 1px rgba(100,100,100,.2);
    color: #fff;
  }

  .swiper-wrapper {
    width: 100%;
    overflow: hidden;
  }

  .swiper-img{
    width: 100%;
    height: 300px;
  }
 
</style>
